﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using OpenCvSharp;
using System.Collections.Specialized;
using System.Collections;
using System.Diagnostics;

namespace FacePrep
{
    class FeretFace:FaceCrop
    {
        // constructor
        public FeretFace(double haarFaceScaleFactor, double haarEyeScaleFactor)
            :base(haarFaceScaleFactor, haarEyeScaleFactor)
        {
            this.templateWidthScale = 1 / 0.60; // 40%
            this.templateHeightScale = 1 / 0.40; // 60%
        }

        // constructor 2
        public FeretFace(DirectoryInfo dataDir, DirectoryInfo outputDir, double haarFaceScaleFactor, double haarEyeScaleFactor)
            :base(dataDir, outputDir, haarFaceScaleFactor, haarEyeScaleFactor)
        {
            this.templateWidthScale = 1 / 0.60; // 40%
            this.templateHeightScale = 1 / 0.40; // 60%
        }

        public override void prepareData()
        {   
            // set the working directory
            DirectoryInfo projectDir = new DirectoryInfo(Directory.GetCurrentDirectory());
            try
            {                
                Directory.SetCurrentDirectory(dataDir.ToString());
            }
            catch (DirectoryNotFoundException e)
            {
                Console.WriteLine("Directory does not exist. {0}", e);
            }

            // get the sample file list to work with
            string imageFilename;
            using (StreamReader sr = new StreamReader(sampleListFilename))
            {
                while ((imageFilename = sr.ReadLine()) != null)
                {
                    //imageFilename = Path.Combine(Directory.GetCurrentDirectory(), imageFilename);
                    sampleList.Add(imageFilename);
                }
            }

            using (StreamReader sr = new StreamReader(failedListFilename))
            {
                while ((imageFilename = sr.ReadLine()) != null)
                {
                    failedList.Add(imageFilename);
                }
            }


            using (StreamReader sr = new StreamReader(succeedListFilename))
            {
                while ((imageFilename = sr.ReadLine()) != null)
                {
                    succeededList.Add(imageFilename);
                }
            }


            // change the working directory back to the project directory
            //Directory.SetCurrentDirectory(projectDir.ToString());
        }
    }
}
